package com.leetcode.no590;
import java.util.*;

class Node {
    public int val;
    public List<Node> children;

    public Node() {}

    public Node(int _val) {
        val = _val;
    }

    public Node(int _val, List<Node> _children) {
        val = _val;
        children = _children;
    }
};

public class Solution {
    List<Integer> res = new ArrayList<>();

    public List<Integer> postorder(Node root) {

        recursion(root);
        return res;
    }

    public void recursion(Node root){
        if(root ==null){
            return;
        }

        // 孩子
        for(Node aChild: root.children){
            if(aChild != null){
                recursion(aChild);
            }
        }
        // 根
        res.add(root.val);

    }
}
